<?php

// No direct access.
defined('_JEXEC') or die;

jimport('joomla.application.component.controlleradmin');

class AppcategorysControllerAppcategorys extends JControllerAdmin
{
	public function __construct($config = array())
	{
		parent::__construct($config);

		$this->registerTask('unfeatured',	'featured');
		$this->registerTask( 'unpublish', 'publish' );
	}

	public function getModel($name = 'Appcategorys', $prefix = 'AppcategorysModel', $config = array('ignore_request' => true))
	{
		$model = parent::getModel($name, $prefix, $config);

		return $model;
	}

	public function publish()
	{
		//update xuong csdl
		$db = &JFactory::getDbo();
		//$query = 'UPDATE aas_app_category SET is_delete=';
		//$db->setQuery($query);



		global $option;
		$cid = JRequest::getVar( 'cid', array(), '', 'array' );
		//var_export($this->task);
		//JError::raiseWarning(500, 'CO len nam oi'.$cid[0]);
		if( $this->task == 'publish')
		{
			$publish = 0;
		}
		else
		{
			$publish = 1;
		}
		$query = 'UPDATE aas_app_category SET is_delete='.(int)$publish.
					' WHERE id='.(int)$cid[0];
		$db->setQuery($query);
		$db->execute();
		//JError::raiseWarning(500, $query);
		//$projectTable =& JTable::getInstance('event', 'Table');
		//$projectTable->publish($cid, $publish);
		$link = 'index.php?option=com_appcategorys&view=appcategorys';
                //JError::raiseWarning(500, $link);
		$this->setRedirect($link);

	}
}
